<?php
namespace app\session\controller;

use think\Controller;
use think\facade\Session;

class PageController extends Controller
{
    protected $prefix="main";
    protected $key="test";
    protected $value="hello world !";
    public function index()
    {
        $this->assign("id",Session::id());
        $this->assign("value",session($this->key));
        $this->assign("prefix_value",session($this->key,'',$this->prefix));
        return $this->fetch();
    }
    public function create()
    {
        session($this->key,$this->value);
        session($this->key,$this->value,$this->prefix);
        $this->redirect("index");
    }
    public function destroy()
    {
        session($this->key,null);
        session($this->key,null,$this->prefix);
        $this->redirect("index");
    }
    public function transfer()
    {
        Session::transfer();
        $this->redirect("index");
    }
    public function ban()
    {
        return $this->fetch();
    }
    public function doBan()
    {
        if(!$id=input("id")){
            $this->error("id不能为空");
        }
        Session::ban($id);
        $this->redirect("index");
    }
}
